]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/volume: Always look up device objects
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 8 Nov 2023 18:41:18 +0000 (19:41 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 21 Nov 2023 18:50:46 +0000 (18:50 +0000)
Gvc may clean its device cache after we set up the device menu,
which can lead to failed assertions when using the "old" object
to later switch the device from a callback.

Make sure this doesn't happen by looking up the ID again from
the callback.

Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7173
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3011>

js/ui/status/volume.js

index 7c9b14b933aebaa9b8599f072922b3b2fc5eb29e..c9abb4fca078b52693e3fd0cc577591efa171d2c 100644 (file)
@@ -138,7 +138,13 @@ const StreamSlider = GObject.registerClass({
             ? `${description} – ${origin}`
             : description;
         const item = new PopupMenu.PopupImageMenuItem(name, device.get_gicon());
-        item.connect('activate', () => this._activateDevice(device));
+        item.connect('activate', () => {
+            const dev = this._lookupDevice(id);
+            if (dev)
+                this._activateDevice(dev);
+            else
+                console.warn(`Trying to activate invalid device ${id}`);
+        });
 
         this._deviceSection.addMenuItem(item);
         this._deviceItems.set(id, item);